package com.cytech.cloudclinic.adapter;

import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.cytech.cloudclinic.R;
import com.cytech.cloudclinic.bean.DrugTag;
import com.cytech.cloudclinic.bean.Illness;

import java.util.List;

/**
 * 疾病列表适配器
 */
public class IllnessAdapter extends BaseQuickAdapter<Illness, BaseViewHolder> {
    private int currentPos = 0;

    public IllnessAdapter(List<Illness> data) {
        super(R.layout.item_illness, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, Illness illness) {
        TextView lableTv = baseViewHolder.getView(R.id.item_drug_category_name);
        lableTv.setText(illness.name);

        if(baseViewHolder.getAdapterPosition()==currentPos){
            lableTv.setBackground(ContextCompat.getDrawable(getContext(),R.drawable.shape_round_real_bg_e9f2fe));
            lableTv.setTextColor(ContextCompat.getColor(getContext(),R.color.colorPrimary));
        }else{
            lableTv.setBackground(ContextCompat.getDrawable(getContext(),R.drawable.shape_round_real_bg_gray_10));
            lableTv.setTextColor(ContextCompat.getColor(getContext(),R.color.color_333333));
        }
    }

    public void setCurrentPos(int currentPos) {
        this.currentPos = currentPos;
        notifyDataSetChanged();
    }
}
